package tests;

import common.Utils;
import org.openqa.selenium.By;

public class ListPage extends Utils {
    public static String url=detailUrl;
    public ListPage() {
        super(url);
    }
    //检查列表页元素是否显示正常
    public void checkListPage() {
        //检查列表页左上角头像是否可见
        driver.findElement(By.cssSelector("#sk-layout > div > div > section > div.ant-pro-layout-container > header.ant-layout-header.ant-pro-layout-header.ant-pro-layout-header-fixed-header.ant-pro-layout-header-mix.ant-pro-layout-header-fixed-header-action.ant-pro-layout-header-header > div > div.ant-pro-global-header-logo.ant-pro-global-header-logo-mix > a > img"));
       //检查列表页左上图标题是否可见
        driver.findElement(By.cssSelector("#sk-layout > div > div > section > div.ant-pro-layout-container > header.ant-layout-header.ant-pro-layout-header.ant-pro-layout-header-fixed-header.ant-pro-layout-header-mix.ant-pro-layout-header-fixed-header-action.ant-pro-layout-header-header > div > div.ant-pro-global-header-logo.ant-pro-global-header-logo-mix > a > h1"));
       //检查右上角问好小图标是否可见
        driver.findElement(By.cssSelector("#sk-layout > div > div > section > div.ant-pro-layout-container > header.ant-layout-header.ant-pro-layout-header.ant-pro-layout-header-fixed-header.ant-pro-layout-header-mix.ant-pro-layout-header-fixed-header-action.ant-pro-layout-header-header > div > div.ant-pro-global-header-right-content > div > div > div > div:nth-child(1) > span"));//
       //检查右上角设置小图标是否可见
        driver.findElement(By.cssSelector("#sk-layout > div > div > section > div.ant-pro-layout-container > header.ant-layout-header.ant-pro-layout-header.ant-pro-layout-header-fixed-header.ant-pro-layout-header-mix.ant-pro-layout-header-fixed-header-action.ant-pro-layout-header-header > div > div.ant-pro-global-header-right-content > div > div > div > div:nth-child(1) > span"));
      //检查图片和用户名是否可见
        driver.findElement(By.cssSelector("#sk-layout > div > div > section > div.ant-pro-layout-container > header.ant-layout-header.ant-pro-layout-header.ant-pro-layout-header-fixed-header.ant-pro-layout-header-mix.ant-pro-layout-header-fixed-header-action.ant-pro-layout-header-header > div > div.ant-pro-global-header-right-content > div > div > div > span > div"));
    }
    //检查首页中的元素以及功能
    public void checkHomePage() throws InterruptedException {

        //检查列表页的目录是否可见
        driver.findElement(By.cssSelector("#sk-layout > div > div > section > aside > div > div:nth-child(1) > ul"));
        System.out.println("列表页目录元素显示正常");

        //点击列表中的首页查看首页中的元素是否可见
        String Home_Page_Title = driver.findElement(By.cssSelector("#sk-layout > div > div > section > div.ant-pro-layout-container > main > div > div.ant-page-header.ant-pro-page-container-warp-page-header.ant-pro-page-container-warp-page-header.ant-page-header-has-breadcrumb.ant-page-header-ghost > div.ant-page-header-heading > div > span")).getText();
        //校验
        assert Home_Page_Title.equals("首页");
        //首页中的头像是否可见
        driver.findElement(By.cssSelector("#sk-layout > div > div > section > div.ant-pro-layout-container > main > div > div.ant-page-header.ant-pro-page-container-warp-page-header.ant-pro-page-container-warp-page-header.ant-page-header-has-breadcrumb.ant-page-header-ghost > div.ant-page-header-content > div > div > div > div > div > div.avatar___3ZBop > span > img"));
        //首页中的问卷数字段是否可见
        String Number_of_questionnaires =driver.findElement(By.cssSelector("#sk-layout > div > div > section > div.ant-pro-layout-container > main > div > div.ant-page-header.ant-pro-page-container-warp-page-header.ant-pro-page-container-warp-page-header.ant-page-header-has-breadcrumb.ant-page-header-ghost > div.ant-page-header-content > div > div > div > div > div > div.extraContent___3rMo7 > div:nth-child(1) > div > div.ant-statistic-title")).getText();
        //校验
        assert Number_of_questionnaires.equals("问卷数");
        //首页中的考试数字段是否可见
        String Number_of_exams=driver.findElement(By.cssSelector("#sk-layout > div > div > section > div.ant-pro-layout-container > main > div > div.ant-page-header.ant-pro-page-container-warp-page-header.ant-pro-page-container-warp-page-header.ant-page-header-has-breadcrumb.ant-page-header-ghost > div.ant-page-header-content > div > div > div > div > div > div.extraContent___3rMo7 > div:nth-child(2) > div > div.ant-statistic-title")).getText();
        //校验
        assert Number_of_exams.equals("考试数");
//        //首页中我的考试字段是否可见
//        String My_Exams=driver.findElement(By.cssSelector("#rc-tabs-6-tab-exam")).getText();
//        //校验
//        assert My_Exams.equals("我的考试");
//        //首页中我的问卷字段是否可见
//        String My_Questionnaires=driver.findElement(By.cssSelector("#rc-tabs-6-tab-survey")).getText();
//        //校验
//        assert My_Questionnaires.equals("我的问卷");
//        //首页中我的问卷记录是否可见
//        String My_Survey_Records=driver.findElement(By.cssSelector("#rc-tabs-6-tab-surveyHistory")).getText();
//        //校验
//        assert My_Survey_Records.equals("我的问卷记录");
//        //首页中我的考试记录是否可见
//        String My_Exam_Records=driver.findElement(By.cssSelector("#rc-tabs-6-tab-examHistory")).getText();
//        //校验
//        assert My_Exam_Records.equals("我的考试记录");
        //检查首页中框架是否可见
        driver.findElement(By.cssSelector("#sk-layout > div > div > section > div.ant-pro-layout-container > main > div > div.ant-pro-grid-content > div > div > div > div.ant-col.ant-col-xs-24.ant-col-sm-24.ant-col-md-24.ant-col-lg-24.ant-col-xl-16 > div > div"));
        //首页中快速开始/便携导航字段是否可见
        String Quick_Start_or_Portable=driver.findElement(By.cssSelector("#sk-layout > div > div > section > div.ant-pro-layout-container > main > div > div.ant-pro-grid-content > div > div > div > div.ant-col.ant-col-xs-24.ant-col-sm-24.ant-col-md-24.ant-col-lg-24.ant-col-xl-8 > div > div.ant-card-head > div > div")).getText();
        //校验
        assert Quick_Start_or_Portable.equals("快速开始/便携导航");
        //首页中创建问卷字段是否可见
        String Create_Survey=driver.findElement(By.cssSelector("#sk-layout > div > div > section > div.ant-pro-layout-container > main > div > div.ant-pro-grid-content > div > div > div > div.ant-col.ant-col-xs-24.ant-col-sm-24.ant-col-md-24.ant-col-lg-24.ant-col-xl-8 > div > div.ant-card-body > div > a:nth-child(1)")).getText();
        //校验
        assert Create_Survey.equals("创建问卷");
        //首页中创建考试字段是否可见
        String Create_Exam=driver.findElement(By.cssSelector("#sk-layout > div > div > section > div.ant-pro-layout-container > main > div > div.ant-pro-grid-content > div > div > div > div.ant-col.ant-col-xs-24.ant-col-sm-24.ant-col-md-24.ant-col-lg-24.ant-col-xl-8 > div > div.ant-card-body > div > a:nth-child(2)")).getText();
        //校验
        assert Create_Exam.equals("创建考试");

        //点击我的考试，出现的界面是否可见
        driver.findElement(By.cssSelector("#sk-layout > div > div > section > div.ant-pro-layout-container > main > div > div.ant-pro-grid-content > div > div > div > div.ant-col.ant-col-xs-24.ant-col-sm-24.ant-col-md-24.ant-col-lg-24.ant-col-xl-16 > div > div > div > div.ant-tabs-nav > div.ant-tabs-nav-wrap > div > div:nth-child(1)")).click();
        System.out.println("点击我的考试按钮");
        //点击考试记录，出现的界面是否正常
        System.out.println("我的考试界面显示正常");

        //点击我的问卷，出现的界面是否正常
        driver.findElement(By.cssSelector("#sk-layout > div > div > section > div.ant-pro-layout-container > main > div > div.ant-pro-grid-content > div > div > div > div.ant-col.ant-col-xs-24.ant-col-sm-24.ant-col-md-24.ant-col-lg-24.ant-col-xl-16 > div > div > div > div.ant-tabs-nav > div.ant-tabs-nav-wrap > div > div:nth-child(2)")).click();
        System.out.println("点击我都问卷按钮");

        System.out.println("我的问卷界面显示正常");

        //点击问卷记录，出现的界面是否正常
        driver.findElement(By.cssSelector("#sk-layout > div > div > section > div.ant-pro-layout-container > main > div > div.ant-pro-grid-content > div > div > div > div.ant-col.ant-col-xs-24.ant-col-sm-24.ant-col-md-24.ant-col-lg-24.ant-col-xl-16 > div > div > div > div.ant-tabs-nav > div.ant-tabs-nav-wrap > div > div:nth-child(3)")).click();
        System.out.println("点击问卷记录按钮");
        System.out.println("问卷记录界面显示正常");

        //点击考试记录，出现的界面是否正常
        driver.findElement(By.cssSelector("#sk-layout > div > div > section > div.ant-pro-layout-container > main > div > div.ant-pro-grid-content > div > div > div > div.ant-col.ant-col-xs-24.ant-col-sm-24.ant-col-md-24.ant-col-lg-24.ant-col-xl-16 > div > div > div > div.ant-tabs-nav > div.ant-tabs-nav-wrap > div > div:nth-child(4)")).click();
        System.out.println("点击考试记录按钮");
        System.out.println("考试记录界面显示正常");

    }
    //点击首页中的快速开始/便携导航中的创建问卷，出现的界面是否正常
     public void checkCreateSurvey() throws InterruptedException {
         //点击首页中的快速开始/便携导航中的创建问卷
         driver.findElement(By.cssSelector("#sk-layout > div > div > section > div.ant-pro-layout-container > main > div > div.ant-pro-grid-content > div > div > div > div.ant-col.ant-col-xs-24.ant-col-sm-24.ant-col-md-24.ant-col-lg-24.ant-col-xl-8 > div > div.ant-card-body > div > a:nth-child(1)")).click();
         System.out.println("点击创建问卷按钮");
         Thread.sleep(1000);
         driver.findElements(By.cssSelector("#editor > div.survey-sidebar-panel > div.survey-sidebar-panel-tabs"));

         //点击创建问卷页面中的“开始编辑”按钮
         System.out.println("创建问卷界面显示正常");
         //回退页面
         driver.navigate().back();
         System.out.println("回退到页面");
         //点击首页中的快速开始/便携导航中的创建考试
         driver.findElement(By.cssSelector("#sk-layout > div > div > section > div.ant-pro-layout-container > main > div > div.ant-pro-grid-content > div > div > div > div.ant-col.ant-col-xs-24.ant-col-sm-24.ant-col-md-24.ant-col-lg-24.ant-col-xl-8 > div > div.ant-card-body > div > a:nth-child(2)")).click();
         //查看创建考试界面是否正常

         String create_exem = driver.findElement(By.cssSelector("#root > div > div.survey-main-navigator > div.actions-container > div:nth-child(2)")).getText();
         //校验
         assert create_exem.equals("您已完成本次考试。");
         System.out.println("创建考试界面显示正常");
         //回退页面
         driver.navigate().back();
         System.out.println("回退到页面");
         //保存url
         detailUrl=driver.getCurrentUrl();
     }

}
